#include "expression.h"

#include "utils/expressionengine.h"
#include "wfnet.h"

using namespace wfnet;

Expression::~Expression()
{

}

nid Expression::getId() const
{
    return m_id;
}

const TypeName Expression::returns() const
{
    return m_returnedType;
}

Type* Expression::eval()
{
    Type* ret = ExpressionEngine::getInstance()->eval(m_expression, m_binding,
        m_variables, m_systemVariables);

    return ret;
}

void Expression::setBinding(const Binding& binding)
{
    m_binding = binding;
}

void Expression::clearBinding()
{
    m_binding.clear();
}

uint Expression::getExpressionType() const
{
    return m_expressionType;
}

UserVariables Expression::getUserVariables() const
{
    return m_variables;
}

Expression::Expression(WfNet* parent, nid id, const Expr& expr,
    const TypeName& returnedType,
    const UserVariables& variables,
    const SystemVariables& systemVariables,
    uint exprType) :
        QObject(parent),
        IExpression(),
        m_id(id),
        m_expression(expr),
        m_returnedType(returnedType),
        m_binding(),
        m_variables(variables),
        m_systemVariables(systemVariables),
        m_expressionType(exprType)
{

}
